#ifndef LOG_CC
#define LOG_CC
#include<string>
#include<fstream>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include "def.hpp"
#include "utils.hpp"
#include "log.hpp"

using namespace std;

PuzaLogger* PuzaLogger::m_pInstance = NULL;

PuzaLogger* PuzaLogger::Instance()
{
  if (!m_pInstance)   // Only allow one instance of class to be generated.
    m_pInstance = new PuzaLogger;
  return m_pInstance;
}

PuzaLogger::PuzaLogger(){
  log_file_name = PuzaDEF::Instance()->output_file_name + ".log";
}

string PuzaLogger::GetCurrentTime(){
  time_t rawtime;
  time(&rawtime);
  return ctime(&rawtime);
}

void PuzaLogger::PutString(string s){
  PuzaDEF::Instance()->LogFile << s << " " << GetCurrentTime();  
  PuzaDEF::Instance()->LogFile.flush();
}

void PuzaLogger::Start(){
  PuzaDEF::Instance()->LogFile.open(log_file_name.c_str());
  PutString("Starting Puza Topic Modeling.");
}



void PuzaLogger::End(){
  PutString("Completed.");
  PuzaDEF::Instance()->LogFile.close();
}

#endif
